package cn.edu.gdu.quizpractice.entity;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Reference;

import java.time.LocalDateTime;


/**
* 选择题实体类
* */
@Data
@TableName("t_choicequestions")
@NoArgsConstructor
@AllArgsConstructor
public class ChoiceQuestion {

    @Id
    @ExcelIgnore  // 关键注解：禁止映射 Excel 列到此字段
    @TableId(type = IdType.AUTO) // MyBatis-Plus自增主键注解
    private Integer cquestionId;

    @NotBlank(message = "题库名称不能为空")  // 添加校验注解
    @ExcelProperty("题库名称")
    @TableField("b_name")
    @JsonProperty("bName")  // 显式映射JSON键名
    private String bName;

    /**
     * 题目分类
     */
    @ExcelProperty("分类")
    private String categoryName;

    /**
     * 题目内容
     */
    @NotBlank(message = "题目内容不能为空")
    @ExcelProperty("题目内容")
    private String cqContent;

    @NotBlank(message = "选项不能为空")
    @ExcelProperty("选项A")
    private String optionA;

    @NotBlank(message = "选项不能为空")
    @ExcelProperty("选项B")
    private String optionB;

    @NotBlank(message = "选项不能为空")
    @ExcelProperty("选项C")
    private String optionC;

    @NotBlank(message = "选项不能为空")
    @ExcelProperty("选项D")
    private String optionD;

    /**
     * 正确答案,只能是ABCD的排列组合
     */
    @NotBlank(message = "正确答案不能为空")
    @Pattern(regexp = "^(?!.*(.).*\\1)[A-D]{1,4}$", message = "输入的正确答案有误")
    @ExcelProperty("正确答案")
    private String correctAnswer;

    /**
     * 解析
     */
    @NotBlank(message = "解析不能为空")
    @ExcelProperty("解析")
    private String analysis;

    /**
     * 题目难度(1-5)
     */
    @Pattern(regexp = "^[1-5]$", message = "题目难度只能是1-5")
    @ExcelProperty("难度")
    private Integer difficulty;


    /**
    * 是否是多选(0否1是)
    */
    @Pattern(regexp = "^[0-1]$", message = "是否是多选只能是0或1(0表示不是多选,即单选,1表示是多选)")
    @ExcelProperty("是否多选")
    @TableField("is_multiple")
    @JsonProperty("isMultiple")  // 显式映射JSON键名
    private Boolean isMultiple;

} 